<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page isELIgnored="false" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>账号管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
    <form id="searchBar">
	    <input type="hidden" id="flag" value="${flag}">
	    <div class="fieldset1 clearFix">
	    <div class="fieldBox">
						<div class="label">账号</div>
						<div class="field">
							<input name="accNum" id="accNum" type="text" class="ui-textbox" value="">
						</div>
		</div>
		<div class="fieldBox">
						<div class="label">账户用途：</div>
						<div class="field">
								<select name="accTypCd" id="accTypCd" data-value=" ">
								<option value=" " seleted>请选择</option>
								<c:forEach items="${accTypCdList }" var="kv">
									<option value="${kv.key }">${kv.value }</option>
								</c:forEach>
							</select>
						</div>
		</div>
		
		<div class="clearFix"></div>
	    <div class="btnsBox formBtns notRight">
	    		<span id="searchBtn" class="sq-button-round">查询</span>
	    		<span id="clearBtn" class="sq-button-round" onclick="clearBtn();">清空</span>
				<span class="sq-button sq-button-round" id="addBtn" onclick="add('');">添加自有账户</span>
						
		</div>
		</div>
	</form>
    </div>
   
    <div id="ligergrid1" class="sq-grid"></div>
</div>


<script type="text/javascript">
//清空按钮事件
function clearBtn() {
	$("#resetBtn").click(); //重置 input-text
	var form = new liger.get("searchBar");
	form.setData({ //重置select等特殊表单
		"accNum" : "",
		"accTypCd" : ""
	});
}
    var grid = null;
    $(function () {
    	
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/rfbase/fribaseinfo/initBaList.do',
            method: 'get',
            columns: [
                {display: '银行账号', name: 'accNum',align:'left', minWidth: 180},
                {display: '账户用途', name: 'accTypCdNm', minWidth: 150},
                {display: '机构名称', name: 'fundRasInsIdNm', minWidth: 200,
	                render:function(rowdata, rowindex, value){
	                	var h=rowdata.fundRasInsIdNm;
	                	//判断业务线是否为空
	                	if(rowdata.bussinessLine){
	                		h=h+" "+'<font color="red">('+rowdata.bussinessLineNm+')</font>';
	                	}
	                	return h;
	                }
                },
                {display: '可投放款项', name: 'purpCdsNm', minWidth: 150},
                {display: '可用余额', name: 'currLimAmt',align:'right', minWidth: 50},
                {display: '是否正常', name: 'accStsCdNm', minWidth: 50},
                {display: '所属机构', minWidth: 50,render: function (rowdata, rowindex, value){
            		if(rowdata.bizFlag=='1')
            			return "狮桥";
            		else if(rowdata.bizFlag=='0') 
            			return "机构";
                	}
                },
               
                {display: '优先级', minWidth: 100,
                	render: function (rowdata, rowindex, value){
                		var h='';
                		if(rowdata.purpCdsNm==null||rowdata.purpCdsNm=='')
                			return h;	
                        if(rowindex==0){
                        	h="<img width='40px' height='20px' src='<%=path%>/resource/lib/images/u147.png'/>";
                        	h+="  ";
                        	h+="<img width='40px'  onclick='change("+rowdata.id+",0)' height='20px' src='<%=path%>/resource/lib/images/u145.png'/>";
                        }else if(grid.data.total==(rowindex+1)){
                        	h="<img width='40px'  onclick='change("+rowdata.id+",1)' height='20px' src='<%=path%>/resource/lib/images/u143.png'/>";
                        	h+="  ";
                        	h+="<img width='40px'  height='20px' src='<%=path%>/resource/lib/images/u161.png'/>";
                        }else{
                        	h="<img width='40px'  onclick='change("+rowdata.id+",1)' height='20px' src='<%=path%>/resource/lib/images/u143.png'/>";
                        	h+="  ";
                        	h+="<img width='40px' onclick='change("+rowdata.id+",0)' height='20px' src='<%=path%>/resource/lib/images/u145.png'/>";
                        }
                       
                        return h;
                    }
                
                },
                {display: '操作', minWidth: 150,align:'left',
                    render: function (rowdata, rowindex, value){
                        var h='<a onclick="add('+rowdata.id+','+1+');"></i>查看</a>';
                        h+=' | <a onclick="add('+rowdata.id+');"></i>修改</a>';
                        if(rowdata.accTypCd !='6'){
                        	
                        	h+=' | <a onclick="preabs('+rowdata.id+','+rowdata.fundRasInsId+');"></i>批次</a>';
                   		}
                        return h;
                    }
                },
            ],

            usePager: false,
            checkbox: false,
            rownumbers:true,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            
	        isScroll: true
	       
        });
        grid.setHeight(100);
        $("#searchBar").ligerForm();
    	
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         var insUseCd = $("#insUseCd").val();
        	 data["insUseCd"]=insUseCd;
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
    

    });

    function add(id,flag){
    	if(flag==1){
        	$.ligerDialog.SQopen({
                cls: 'noBorder_Dialog',
                width: 800,
                height:540,
                title : '账户详情',
                url:'<%=path%>/rfbase/fribaseinfo/toAddPayAccPage.do?id='+id+'&flag='+flag
            });
    	}else{
        	$.ligerDialog.SQopen({
                cls: 'noBorder_Dialog',
                width: 800,
                height:540,
                title : '添加自有帐户',
                url:'<%=path%>/rfbase/fribaseinfo/toAddPayAccPage.do?id='+id+'&flag='+flag
            });
    	}
    	
    }
  //pre-abs来款记录
	function preabs(accid,id){
		
		var params="?id="+id+"&accId="+accid;

		Add_navTab('fnc_pre_abs_'+id,'机构账户额度管理','<%=path%>/rfbuss/fncpreabslim/toListPage.do'+params);
	
	}
	</script>
	<script type="text/javascript">
  	function change(id,num){
	  $.ajax({
  		type: 'post',
  		dataType:'json',
  		data:{
  			id:id,
  			num:num
  		},
  		url: '<%=path%>/rfbase/fribaseinfo/changeNum.do',
			success : function(msg) {
				if (msg.success == 1) {
					grid.reload();
				} else {
					UIUtils.alertErrorHold1(msg.info);
				}
			}
		});
	  }
	</script>

</body>
</html>